"""
个人额度及贷款记录清理
目的：预授信或自主申请前执行改模块进行数据初始化
"""

import requests
from common import public_login
from db_fixture import mycat_execute

# 删除个人所有贷款记录
gr_dk_jl = 'http://plsadmpre.cnsuning.com/plsadm/quota/crtQuotarRefresh/deleteLoanInfoByIds.do'
# 重置客户申请
gr_kh_sq = 'http://plsadmpre.cnsuning.com/plsadm/quota/crtQuotarRefresh/deleteDataCustomerApplyByIds.do'
# 更新redis缓存
redis_sx = 'http://plsadmpre.cnsuning.com/plsadm/quota/crtQuotarRefresh/updateQuotaByIds.do'
dele = [gr_dk_jl, gr_kh_sq, redis_sx]


def Completely_clean(ids):
    for i in dele:
        base_url = i
        r = requests.post(url=base_url, data={'ids': ids}, headers={'cookie': public_login.gl_cookie()})
        result = r.json()
        print(result)
    print("开始执行delete语句：")
    mycat_execute.sql_tab(idNo=ids)
    print("delete语句执行结束！")


if __name__ == '__main__':
    Completely_clean(ids='310101199104011181')
